//
//  IManager+TrainList.m
//  RocketProject
//
//  Created by chen jiedan on 13-11-28.
//  Copyright (c) 2013年 Rocket. All rights reserved.
//

#import "IManager+TrainList.h"
#import "FrameworkRelativeDefines.h"
#import "NetUrlDefines.h"
#import "RequestUtlity.h"
#import "RCTranlistDataModel.h"
#import "GloableEngineService.h"


@implementation IManager (TrainList)

-(int64_t)requestTrainListWithStartPort:(NSString *)startTrainPort
                            withEndPort:(NSString *)endTrainPort
                          withStartTime:(NSString *)startTime
                          withTrainType:(NSInteger)trainTypeInt
                           withSeatType:(NSInteger)seatTypeInt
                           withTimesort:(NSInteger)timesort
                           withPricesort:(NSInteger)pricesort
                           withDelegate:(id<IManagerDelegate>)delegate
{
    NSString *urlSuffix = [NSString stringWithFormat:kTrainListPrefix,startTrainPort,endTrainPort,startTime,trainTypeInt,seatTypeInt,0,0,timesort,pricesort];
    
    NSString *url = [RequestUtlity getFormattedUrl:urlSuffix];
    
    KFLog(@"request url %@",url);
    return [[IDataProvider sharedInstance] asyncFetchDataWithUserInfo:url
                                                             userInfo:nil
                                                      withCachePolicy:IDataCachePolicyLocalFileAndNetwork
                                                   withDataParseClass:[RCTranlistDataModel class]
                                                     withDataDelegate:delegate];
}



-(int64_t)requestPlaneListWithStartPort:(NSString *)fromcity
                            withEndPort:(NSString *)tocity
                          withStartTime:(NSString *)fromdate
                           withTripType:(NSInteger)type
                           withSeatType:(NSInteger)carbins
                           withTimesort:(NSInteger)timesort
                          withPricesort:(NSInteger)pricesort
                           withDelegate:(id<IManagerDelegate>)delegate
{
    NSString *bduss = [[GloableEngineService sharedInstance] bduss];
    NSString *urlSuffix = [NSString stringWithFormat:kPlaneListPrefix,bduss,fromcity,tocity,fromdate,carbins,type,0,timesort,pricesort];
    
    NSString *url = [RequestUtlity getFormattedUrl:urlSuffix];
    
    KFLog(@"request url %@",url);
    return [[IDataProvider sharedInstance] asyncFetchDataWithUserInfo:url
                                                             userInfo:nil
                                                      withCachePolicy:IDataCachePolicyLocalFileAndNetwork
                                                   withDataParseClass:[RCPlanelistDataModel class]
                                                     withDataDelegate:delegate];
}

@end
